package hcs.ops.test;

import java.util.Scanner;

import org.openqa.selenium.WebDriver;

import hcs.ops.func.*;


public class Run {

	public static WebDriver driver;
	public static String lName;
	public static String pin;
	
	static
	Webdriver d = new Webdriver();
	static
	Login log = new Login();
	static
	Logout out = new Logout();
	static
	Hcs_NewPatient newPatient = new Hcs_NewPatient();
	static
	Hcs_Admission admit = new Hcs_Admission();
	static
	Hcs_Nursing pack = new Hcs_Nursing();
	static
	Web_App app = new Web_App();
	static
	Hcs_Billing bill = new Hcs_Billing();

	public static void main(String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		System.out.println(" "
				+ "1 = Full Payment "
				+ "\n 2 = Partial Payment "
				+ "\n 3 = Decimal Payment "
				+ "\n 4 = Visa Payment"
				+ "\n 5 = Mastercard Payment"
				+ "\n 6 = Payment with Guarantor"
				+ "\n 7 = Payment without Guarantor"
				+ "\n 8 = OPS Payment and Bill Discharge"
				+ "\n 9 = Verify Balance of newly admitted patients"
				+ "\n 10 = Verify SOA of OPS and HCS"
				+ "\n 11 = Cancel SOA of OPS"
				);
		System.out.println("Please select a number that corresponds to the transaction.");
		String option = scan.nextLine();
		scan.close();
		
		if(option.equals("9")){
			driver = d.startUp();
			log.hcs(driver, "admission"); 									
			String getIt = newPatient.createPatient(driver, "adult");
			String[] arrString = getIt.split(",");
			lName = arrString[0];
			pin = arrString[1];
			admit.admin(driver, pin);
			out.hcs(driver);
		}else{
			test_data();
		}
		
		if(option.equals("1")){
			full_payment();
		}
		else if(option.equals("2")){
			partial_payment();
		}
		else if(option.equals("3")){
			decimal_payment();
		}
		else if(option.equals("4")){
			visa_payment();
		}
		else if(option.equals("5")){
			mastercard_payment();
		}
		else if(option.equals("6")){
			withguarantor_payment();
		}
		else if(option.equals("7")){
			noguarantor_payment();
		}
		else if(option.equals("8")){
			until_discharge_payment();
		}
		else if(option.equals("9")){
			new_admit();
		}
		else if(option.equals("10")){
			soa_ops_hcs();
		}
		else if(option.equals("11")){
			cancel_soa();
		}
	}
	public static void test_data() throws Exception{
		driver = d.startUp();
		log.hcs(driver, "admission"); 									//login
		String getIt = newPatient.createPatient(driver, "adult");
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		admit.admin(driver, pin);
		out.hcs(driver);
		log.hcs(driver, "nursing"); 	
		pack.order(driver, pin); 
		pack.discharge(driver, pin); 									//fill up discharge instructions
		pack.admit(driver, pin); 										//assign pf and discharge
		out.hcs(driver);
	}
	public static void full_payment() throws Exception
	{
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "full");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
		
	}
	public static void partial_payment() throws Exception
	{

		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "partial");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
	}
	public static void decimal_payment() throws Exception
	{
		
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "decimal");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
	}
	public static void visa_payment() throws Exception
	{
		
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "full");
		app.click_agreement(driver);
		app.step_payment(driver, "visa");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
	}
	public static void mastercard_payment() throws Exception
	{
		
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "full");
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
	}
	public static void withguarantor_payment() throws Exception
	{
		
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "with_guarantor");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
	}
	public static void noguarantor_payment() throws Exception
	{
		
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "no_guarantor");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
	}
	public static void until_discharge_payment() throws Exception
	{
		
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "no_guarantor");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
		
		//BILL DISCHARGE
		log.hcs(driver, "billing"); 	
		bill.regular(driver, pin); 
		out.hcs(driver);
	
		log.hcs(driver, "nursing"); 						//print gatepass
		pack.gatepass(driver, pin);
		out.hcs(driver);
	}
	public static void new_admit() throws Exception
	{
		
		
		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.newly_admitted(driver);
		
		
	}
	public static void soa_ops_hcs() throws Exception
	{

		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		String for_checking = app.step2(driver, "no_guarantor");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		
		//FOR CHECKING
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.verifying_payment(driver, for_checking);
		app.view_webapp_soa(driver);
		
		//BILL DISCHARGE
		log.hcs(driver, "billing"); 	
		bill.generate_unofficial_soa(driver, pin); 
		out.hcs(driver);

	}
	public static void cancel_soa() throws Exception
	{

		//START OPS WEBAPP
		app.go_to_ops_web_app(driver);
		app.select_location(driver, "GC");
		app.search_patient(driver, pin, lName);
		app.step2(driver, "no_guarantor");
		app.click_agreement(driver);
		app.step_payment(driver, "mastercard");
		app.view_or(driver);
		

		//BILL DISCHARGE
		log.hcs(driver, "billing"); 	
		bill.cancel_or(driver, pin); 
		out.hcs(driver);

	}
}
